home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1996 May: Tool Chest / Developer CD Series May 1996 (Tool Chest) (Apple Computer) (1996).iso / Tool Chest / Files / XTND 1.3.6 / XTND Headers / XTNDCIncludes / XTNDInterface.h next >
Encoding:
C/C++ Source or Header  |  1992-07-16  |  11.2 KB  |  249 lines  |  [TEXT/MPS ]

  1. /************************************************************************
  2. *                                                                        *
  3. *    XTNDInterface.h                                                        *
  4. *                                                                        *
  5. *    Claris XTND Architecture application header file                    *
  6. *                                                                        *
  7. *    Copyright © 1989-91 Claris Corporation                                *
  8. *    All Rights Reserved                                                    *
  9. *                                                                        *
  10. ************************************************************************/
  11.  
  12. #ifndef __XTNDINTERFACE__
  13. #define    __XTNDINTERFACE__
  14.  
  15. #ifdef applec
  16. #    include <Types.h>
  17. #    include <StandardFile.h>
  18. #endif
  19.  
  20. /* ———— Prototypes for XTND system calls are at the end of this file (for THINK C) ———— */
  21.  
  22.  
  23. /* ———— Defines for XTND Version ———— */
  24.  
  25. #define    xtndVersion        2
  26.  
  27.  
  28. /* ———— Defines for file types ———— */
  29.  
  30. #define    xtndTranslatorFileType    'Fltr'
  31.  
  32.  
  33. /* ———— Defines for resource types ———— */
  34.  
  35. #define    translatorDescription        'FTYP'
  36. #define    textImportType                'FLTI'
  37. #define    textExportType                'FLTE'
  38. #define    pictImportType                'PFLT'
  39. #define ClarisWorksDBImportType        'CWDI'
  40. #define ClarisWorksDBExportType        'CWDE'
  41. #define ClarisWorksSSImportType        'CWSI'
  42. #define ClarisWorksSSExportType        'CWSE'
  43. #define ClarisWorksBothImportType    'CWBI'
  44. #define ClarisWorksBothExportType    'CWBE'
  45.  
  46.  
  47. /* ———— Characteristics values for Flags field in TransDescribe and FTYP ———— */
  48.  
  49. #define    ftypIsSpecial            0x0001
  50. #define    ftypHasPreferences        0x0002    /* Reserved for future use */
  51. #define    ftypNeedsResources        0x0004
  52. #define    ftypWritesResources        0x0008    /* Reserved for future use */
  53. #define    ftypOnlyPreferences        0x0010    /* Reserved for future use */
  54. #define    ftypIsLocalized            0x0020
  55.  
  56.  
  57. /* ———— Type of translators to be included in list ———— */
  58.  
  59. #define    allowTypeMask            0x00FF
  60. #define    allowText                0x0001
  61. #define    allowGraphics            0x0002    /* Reserved for future use */
  62. #define    allowDataBase            0x0004    /* Reserved for future use */
  63. #define    allowPict                0x0008
  64. #define    allowClarisWorks        0x0010    /* Reserved for ClarisWorks */
  65. #define    allowOtherTypes            0x0080    /* Reserved for future use */
  66. #define    allowAllTypes            0x00FF
  67.  
  68.  
  69. /* ———— Use of translators to be included in list ———— */
  70.  
  71. #define    allowUseMask            0xFF00
  72. #define    allowImport                0x0100
  73. #define    allowExport                0x0200
  74. #define    allowOtherUses            0x8000    /* Reserved for future use */
  75. #define    allowAllUses            0xFF00
  76.  
  77.  
  78. /* ———— Error codes which the XTND System can return ———— */
  79.  
  80. #define    badXTNDVersionErr        -9991
  81. #define    noTransMatchErr            -9999
  82.  
  83.  
  84. /* ———— Error codes which a translator can return ———— */
  85.  
  86. #define    badImportFileErr        12
  87. #define    translationCanceledErr    32767
  88.  
  89.  
  90. /* ——————  T Y P E   D E F I N I T I O N S  —————— */
  91.  
  92. #ifndef __XTND__
  93.  
  94. #ifdef THINK_C
  95.     typedef short (* XTNDDlgHookProcPtr)();        /* Have to call this with CallPascalW() in Think C */
  96.  
  97.     #ifndef ModalFilterProcPtr    /* Define this for Think C users who don't already have it defined */
  98.     #define    ModalFilterProcPtr    ProcPtr
  99.     #endif
  100. #else
  101.     typedef pascal short (*XTNDDlgHookProcPtr)(short theItem, DialogPtr theDialog, Ptr theSFParams, Boolean *changedFlag, long unused);
  102. #endif
  103.  
  104.  
  105. /* ———— Translator procedure pointer.  Used for calling external code resources ———— */    
  106.  
  107. typedef    void (*TransProcPtr) (void *paramBlk);
  108.  
  109.  
  110. /* —————— TransDescribe and Related Structures —————— */
  111.  
  112. /* The MatchInfo data stucture defines a single file type (and possibly creator type)    */
  113. /* that a translator can recognize.                                                        */
  114. struct MatchInfo
  115. {
  116.     ResType            docCreator;            /* Document creator, eg MACA - MacWrite    */
  117.     ResType            docType;            /* Document type, eg WORD - MacWrite    */
  118.     Boolean            exactMatch;            /* If TRUE, Creator MUST match            */
  119.     Byte            creatorAndTypeMask;    /* Flags telling which bytes of creator & file type matter; creator is bits 0 - 3 and file type is bits 4 - 7    */
  120. };
  121. typedef struct MatchInfo MatchInfo;
  122.  
  123.  
  124. /* The TransDescribe data stucture defines an import/export translator.  There is one    */
  125. /* of these (corresponds to the 'FTYP' resource) for every import/export translator.    */
  126. struct TransDescribe
  127. {
  128.     short            version;        /* Version of this FTYP (currently 2) */
  129.     ResType            translatorType;    /* Type of translator (ie, 'PFLT' for pictures) */
  130.     short            codeResID;        /* Resource number of translator code resource */
  131.     short            FDIFResID;        /* Resource ID of 'FDIF' (or -1 if none) */
  132.     short            numVersBytes;    /* Number of bytes for version check (zero if no check) */
  133.     long            versBytesOffSet;/* Offset into file for version check */
  134.     unsigned char    versBytes[16];    /* Byte values we are looking for (max 16) */
  135.     short            appWDRefNum;    /* Internal XTND use only - WDRefNum of the directory containing the application */
  136.     short            unused1;        /* Reserved for future use - must be zero for this version */
  137.     short            pathLength;        /* Internal XTND use only - Number of times this file has been translated */
  138.     short            flags;            /* Flags for filter characteristics */
  139.                                     /*    bit 0 - set if this filter won't work with All Available */
  140.                                     /*    bit 1 - reserved for future use - must be zero for this version */
  141.                                     /*    bit 2 - set if this filter must be able to read its resources */
  142.                                     /*    bit 3 - 4 reserved for future use - must be zero for this version */
  143.                                     /*    bit 5 - set if this filter is localized to a particular language */
  144.                                     /*     bit 6 - 13 reserved for future use - must be zero for this version */
  145.                                     /*  bit 14 - 15 Used internally - must be zero for this version */
  146.     short            transIndex;        /* Internal XTND use only - Index of this translator in the list stored by the FINI */
  147.     short            resRefNum;        /* RefNum of resource fork of the translator file when open */
  148.     long            directoryID;    /* Directory ID of the folder containing the filter */
  149.     short            vRefNum;        /* Volume RefNum of volume which contains filter directory */
  150.     unsigned char    fileName[32];    /* Name of file if this is an external filter            */
  151.     short            numMatches;        /* Number of Matches for this translator (0 means all files) */
  152.     MatchInfo        matches[10];    /* An array of all file matches for this translator */
  153.     unsigned char    name[32];        /* Description of translator - appears in pop-up menus */
  154. };
  155. typedef struct TransDescribe TransDescribe;
  156. typedef TransDescribe *TransDescrPtr, **TransDescrHandle;
  157.  
  158. struct SFParamBlock
  159. {
  160.     /* The following fields must be the same in this structure and MatchTranslatorBlock */
  161.     long            allowFlags;            /* --> Flags which indicate Translators to be used */
  162.     long            numStandard;        /* --> How many "standard" file types */
  163.     TransDescrPtr    standard;            /* --> Native file format information */
  164.     OSErr            ioResult;            /* <-- Errors reported through this variable */
  165.     short            chosenTranslator;    /* <-> On input, number of translators supplied in theChosenTranslator; on output, chosen Translator number */
  166.     TransDescrPtr    theChosenTranslator;/* <-> On input, Pointer to list of translators to build popup menu from (UseMyTransList must be true if you supply this list); on output, pointer to the Chosen Translator */
  167.     /* End of common fields */
  168.  
  169.     SFReply            *fileReply;            /* <-- File information is returned through this pointer */
  170.     ResType            applicNativeType;    /* --> Application native document file type, for use when library cannot be found */
  171.     XTNDDlgHookProcPtr    
  172.                     XTNDDlogHook;        /* --> Pointer to your SF dialog hook */
  173.     short            currentMenuItem;    /* <-- chosen menu item (GetFile) */
  174.     short            currentSaveItem;    /* <-- chosen menu item (PutFile) */
  175.     Point            where;                /* --> Top left corner of dialog, if zero, center on screen */
  176.     StringPtr        prompt;                /* --> Pascal string which is displayed on dialog */
  177.     StringPtr        buttonTitle;        /* --> Pascal string which replaces the "Open" or "Save" button */
  178.     StringPtr        origName;            /* --> Pascal string which is the original name in a PutFile */
  179.     short            dialogID;            /* --> Resource number of your dialog template */
  180.     ModalFilterProcPtr
  181.                     SFFilterProc;        /* --> Pointer to your modal dialog filter proc */
  182.     Boolean            showAllFiles;        /* --> TRUE if you want all files to be shown */
  183.     Boolean            useTransList;        /* --> TRUE if you are using chosenTranslator and theChosenTranslator to input a list of translators to be used in creating the popup menu */
  184.     FileFilterProcPtr
  185.                     myFileFilter;        /* --> Pointer to your SF Filter Proc */
  186.     long            unused[1];            /* Reserved for future use, must be zero */
  187. };
  188. typedef struct SFParamBlock SFParamBlock;
  189. typedef SFParamBlock *SFParamPtr;
  190.  
  191.  
  192. /* This parameter block is used to find a translator to read a file */
  193. struct MatchTranslatorBlock
  194. {
  195.     /* The following fields must be the same in this structure and in ClarisFileParamBlock */
  196.     long            allowFlags;            /* --> Flags which indicate Translators to be used */
  197.     long            numStandard;        /* --> How many "standard" file types */
  198.     TransDescrPtr    standard;            /* --> Array of "Native" file formats */
  199.     OSErr            ioResult;            /* <-- IO Result from Claris library */
  200.     short            chosenTranslator;    /* <-> On input, number of translators supplied in theChosenTranslator; on output, chosen Translator number */
  201.     TransDescrPtr    theChosenTranslator;/* <-> On input, Pointer to list of translators to build popup menu from (UseMyTransList must be true if you supply this list); on output, pointer to the Chosen Translator */
  202.     /* End of common fields */
  203.  
  204.     StringPtr        fileName;            /* --> File name */
  205.     short            vRefNum;            /* --> Volume Reference Number of file */
  206.     long            ioDirID;            /* --> Directory id of file */
  207.     Boolean            initFlag;            /* --> TRUE if the list of translators should be rebuilt */
  208.     Boolean            useTransList;        /* --> TRUE if you are using chosenTranslator and theChosenTranslator to input a list of translators to be used in creating the popup menu */
  209.     TransDescrPtr    oneTrans;            /* --> If this is supplied, it will be tried instead of searching all available translators */
  210.     long            unused[4];            /* Reserved for future use, must be zero */
  211. };
  212. typedef    struct MatchTranslatorBlock MatchTranslatorBlock;
  213. typedef MatchTranslatorBlock *MatchTranslatorPtr;
  214.  
  215. struct SelectParamBlock
  216. {
  217.     short            translatorVersion;    /* To select by translator type */
  218.     ResType            translatorType;        /* and version */
  219.     long            includeFlags;        /* Include any of these translator types */
  220.     long            excludeFlags;        /* Exclude all of these translator types */
  221.     short            includeTrans;        /* Include translators with any of these flags set */
  222.     short            excludeTrans;        /* Excluded translator with any of these flags set */
  223.     StringPtr        transName;            /* Include only translators with this name */    
  224.     long            PBVersion;            /* ••• MUST be ONE (1) for this version ••• */
  225.     Boolean            menuSortFlag;        /* TRUE if you want the list sorted and duplicates removed as when the XTND System creates a menu in ClarisGetFile or ClarisPutFile for you */
  226.     Boolean            unused1;            /* Reserved for future use, must be zero */
  227.     short            unused2;            /* Reserved for future use, must be zero */
  228.     long            unused[4];            /* Reserved for future use, must be zero */
  229. };
  230. typedef struct SelectParamBlock SelectParamBlock;
  231. typedef SelectParamBlock *SelectParamPtr;
  232.  
  233.  
  234. /* ———— Prototypes for calls to the XTND system ———— */
  235.  
  236. pascal    OSErr    XTNDInitTranslators(short transVersion, StringPtr xtndSystemName, StringPtr clarisFolderName);
  237. pascal    Boolean    XTNDGetFile(SFParamPtr paramPtr);
  238. pascal    Boolean    XTNDPutFile(SFParamPtr paramPtr);
  239. pascal    OSErr    XTNDLoadTranslator(TransDescrPtr theTranslator, TransProcPtr *transResource);
  240. pascal    OSErr    XTNDReleaseTranslator(TransDescrPtr theTranslator);
  241. pascal    void    XTNDCloseTranslators(void);
  242. pascal    OSErr    XTNDRebuildTransList(void);
  243. pascal    OSErr    XTNDSelectTranslators(SelectParamPtr selectPtr, TransDescrHandle transHandle);
  244. pascal    Boolean    XTNDMatchFile(MatchTranslatorPtr matchPtr);
  245.  
  246. #endif __XTND__
  247.  
  248. #endif
  249.